<script setup>
import { onMounted } from 'vue'
import { ref } from 'vue'
import Top from './components/top'
import Tourist from './components/tourist'
import Sex from './components/sex'
import Age from './components/age'
import Map from './components/map'
import Line from './components/line'
import Rank from './components/rank'
import Counter from './components/counter'
import Year from './components/year'

const screen = ref()

onMounted(() => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%, -50%)`
})

// 定义大屏缩放比例
function getScale(w=1920, h=1080) {
  const ww = window.innerWidth / w
  const wh = window.innerHeight / h
  return ww < wh ? ww : wh
}

window.onresize = () => {
  screen.value.style.transform = `scale(${getScale()}) translate(-50%, -50%)`
}

</script>

<template>
  <div class="container">
    <!-- 数据大屏展示内容区域 -->
    <div class="screen" ref="screen">
      <div class="top">
        <Top></Top>
      </div>
      <div class="bottom">
        <div class="left">
          <div class="tourist">
            <Tourist></Tourist>
          </div>
          <div class="sex">
            <Sex></Sex>
          </div>
          <div class="age">
            <Age></Age>
          </div>
        </div>
        <div class="center">
          <Map class="map"></Map>
          <Line class="line"></Line>
        </div>
        <div class="right">
          <Rank class="rank"></Rank>
          <Year class="year"></Year>
          <Counter></Counter>
        </div>
      </div>
    </div>
  </div>
</template>

<style scoped lang="less">
.container {
  width: 100vw;
  height: 100vh;
  background: url(./images/bg.png) no-repeat;
  background-size: cover;
  .screen {
    position: fixed;
    width: 1920px;
    height: 1080px;
    left: 50%;
    top: 50%;
    transform-origin: left top;
    .top {
      width: 100%;
      height: 40px;
    }
    .bottom {
      display: flex;
      .left {
        flex: 1;
        height: 1040px;
        display: flex;
        flex-direction: column;
        color: white;
        padding: 10px 0 0 40px;
        .tourist {
          flex: 1.2;
          background: url(./images/dataScreen-main-lt.png) no-repeat;
          background-size: 100%;
        }
        .sex {
          flex: 1;
          margin: 30px 0;
        }
        .age {
          flex: 1;
        }
      }
      .center {
        flex: 2.5;
        display: flex;
        flex-direction: column;
        .map {
          flex: 4;
        }
        .line {
          flex: 1.3;
        }
      }
      .right {
        flex: 1;
        padding-right: 50px;
        color: white;
        .rank {
          margin-top: 10px;
        }
        .year {
          margin: 30px 0;
        }
      }
    }
  }
}
</style>
